home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / WEDITS22.ARJ / WETIME.PAS < prev    next >
Pascal/Delphi Source File  |  1991-08-13  |  1KB  |  51 lines

  1. UNIT WETime;
  2. { -- This is the Low Level Time Unit of WWIVEdit 2.2
  3.   -- Last Updated : 8/13/91
  4.   -- Written By:
  5.   --   Adam Caldwell
  6.   --
  7.   -- This code is Public Domain
  8.   --
  9.   -- Purpose : Provide Time Functions
  10.   --
  11.   -- Known Errors : None
  12.   --
  13.   -- Planned Enhancements : None
  14.   --
  15.   -- }
  16. {$R-,V-,S-,B-,E-,N-}   { These Optomize things as much as possible }
  17.  
  18. INTERFACE
  19.  
  20. FUNCTION timer:LongInt;            { Returns number of seconds past midnight  }
  21. FUNCTION time:string;              { returns the time of day in 24 hr Format  }
  22.  
  23. IMPLEMENTATION
  24.  
  25. USES WEString, DOS;
  26.  
  27. FUNCTION timer : LongInt;
  28. { Returns the number of seconds after midnight }
  29. VAR
  30.   h,m,s,s100 : word;
  31.  
  32. BEGIN
  33.   gettime(h,m,s,s100);
  34.   timer  :=  h*longint(3600)+longint(60)*m+longint(1)*s;
  35. END;
  36.  
  37. FUNCTION Time:String;
  38. VAR
  39.   h,m,s,s100:word;
  40.   ampm:string[2];
  41. BEGIN
  42.   GetTime(h,m,s,s100);
  43.   IF h>=12
  44.     THEN ampm:='PM'
  45.     ELSE ampm:='AM';
  46.   IF h>12 THEN dec(h,12)
  47.   ELSE IF h=0 THEN h:=12;
  48.   Time:=cstr(h)+':'+ZExpand(m,2)+':'+ZExpand(s,2)+' '+ampm;
  49. END;
  50.  
  51. END.